/*
 * addon_dllutil.h
 *
 *  Created on: 2010-1-7
 *      Author: gavinkwoe
 */

#ifndef ADDON_FILE_H_
#define ADDON_FILE_H_

#include "addon_features.h"
#include "addon_std.h"
#include "addon_objbase.h"

/*************************************************************************
* NOTIFICATION
*************************************************************************/

/*
 * DESC:
 *	Document was opened successfully
 */
#define ADDON_NTF_FILESEARCH_FOUND		"fsearch.found"

/*
 * DESC:
 *	Document was opened successfully
 */
#define ADDON_NTF_FILESEARCH_FINISH		"fsearch.finish"

/*
 * DESC:
 *	Document was opened successfully
 */
#define ADDON_NTF_FILESEARCH_CANCEL		"fsearch.cancel"

/*************************************************************************
* INTERFACE
*************************************************************************/

ADDON_INTERFACE_( IAddonFile, 1, IObject )
{
	__INHERIT_FROM( IObject )

	ADDON_METHOD( HasOpen )		( ADDON_REF(IObject) thiz, IN unsigned long * flag );
	ADDON_METHOD( Open )		( ADDON_REF(IObject) thiz, IN unsigned short * fname );
	ADDON_METHOD( Create )		( ADDON_REF(IObject) thiz, IN unsigned short * fname );
	ADDON_METHOD( Close )		( ADDON_REF(IObject) thiz );

	ADDON_METHOD( GetSize )		( ADDON_REF(IObject) thiz, OUT unsigned long * size );
	ADDON_METHOD( GetOffset )	( ADDON_REF(IObject) thiz, OUT unsigned long * offset );

	ADDON_METHOD( Seek )		( ADDON_REF(IObject) thiz, IN unsigned long offset );
	ADDON_METHOD( Read )		( ADDON_REF(IObject) thiz, IN void * buff, IN unsigned long size, OUT unsigned long * read_size );
	ADDON_METHOD( Write )		( ADDON_REF(IObject) thiz, IN void * buff, IN unsigned long size, OUT unsigned long * write_size );
};

//ADDON_INTERFACE_( IAddonFileSearch, 1, IObject )
//{
//	__INHERIT_FROM( IObject )
//
//	ADDON_METHOD( HasStart )	( ADDON_REF(IObject) thiz, IN unsigned long * flag );
//	ADDON_METHOD( Start )		( ADDON_REF(IObject) thiz, IN ADDON_REF(IObject) obsrv );
//	ADDON_METHOD( Stop )		( ADDON_REF(IObject) thiz );
//};

/*************************************************************************
* DECLARATION
*************************************************************************/

#if defined(__cplusplus)
extern "C" {
#endif	// #if defined(__cplusplus)
	
ADDON_IMPORT ADDON_REF(IObject)	addon_create_file( void * reserved );
//ADDON_IMPORT ADDON_REF(IObject)	addon_create_filesearch( void * reserved );

#if defined(__cplusplus)
}
#endif	// #if defined(__cplusplus)

/*************************************************************************
* MACRO
*************************************************************************/

#define IAddonFile_VTBL( p )			ADDON_GET_VTBL_(p, IAddonFile)
#define IAddonFile_CALL( p, a )			IAddonFile_VTBL(p)->a
#define IAddonFile_HasOpen( p, a )		IAddonFile_CALL( p, HasOpen )( p, a )
#define IAddonFile_Open( p, a )			IAddonFile_CALL( p, Open )( p, a )
#define IAddonFile_Create( p, a )		IAddonFile_CALL( p, Create )( p, a )
#define IAddonFile_Close( p )			IAddonFile_CALL( p, Close )( p )
#define IAddonFile_GetSize( p, a )		IAddonFile_CALL( p, GetSize )( p, a )
#define IAddonFile_GetOffset( p, a )	IAddonFile_CALL( p, GetOffset )( p, a )
#define IAddonFile_Seek( p, a )			IAddonFile_CALL( p, Seek )( p, a )
#define IAddonFile_Read( p, a, b, c )	IAddonFile_CALL( p, Read )( p, a, b, c )
#define IAddonFile_Write( p, a, b, c )		IAddonFile_CALL( p, Write )( p, a, b, c )

#define IAddonFileSearch_VTBL( p )			ADDON_GET_VTBL_(p, IAddonFileSearch)
#define IAddonFileSearch_CALL( p, a )		IAddonFileSearch_VTBL(p)->a
#define IAddonFileSearch_HasStart( p, a )	IAddonFileSearch_CALL( p, HasStart )( p, a )
#define IAddonFileSearch_Start( p, a )		IAddonFileSearch_CALL( p, Start )( p, a )
#define IAddonFileSearch_Stop( p )			IAddonFileSearch_CALL( p, Stop )( p )

#endif /* ADDON_FILE_H_ */
